<?php
include ("config.php");
echo $scripts;
$what = $_GET['what'];
$param = $_GET['param'];
$id = $_GET['id'];

$error = "Ошибка в параметрах";

if (isset($what) && $what=="login") {
	if (isset($param) && isset($id) && strlen($param) > 0) {

		$r = mysql_query( "SELECT login FROM users WHERE login LIKE '".$param."%' LIMIT 5");
		$total = mysql_num_rows($r);
		if ($total>0) {
			echo "<table class='select'>";
				for ($i=0; $i<$total; $i++) {
					$result = mysql_fetch_array($r);
					echo "<tr><td class='select' onclick=\"document.getElementById('".$id."').value = '".$result[login]."'; hide('list');\">".$result[login]."</td></tr>";
				}
			echo "</table>";
		}
	}
	else echo $error;
} 
else if (isset($what) && $what=="car") {
	if (isset($id) > 0) {
		printCar($id);
	}
	else echo $error;
}
else if (isset($what) && $what=="msg" && $_SESSION["loggedIn"]) {
	include ("messages.php");
}
else if (isset($what) && $what=="info" && ($_SESSION["loggedIn"] || isset($id))) {
	
	if ($id) $uid = $id;
	else $uid = getUserIdByLogin($_SESSION["login"]);
	$user = getUserInfo($uid); // Получаем информацию о пользователе
	
	echo "<table width=100%>
			<tr><td width=200><img width=200 src='photos/".change(photo, $user[photo])."'></td>
			<th class='l' rowspan=3><center>
				<table>
				<tr>
					<td width=180 class=b><img src='images/p.png'> <b>Логин</b></td>
					<td width=200 class=b>$user[login]</td>
				</tr>
				<tr>
					<td class=b><img src='images/p.png'> <b>Зарегистрирован</b></td>
					<td class=b>$user[register]</td>
				</tr>
				<tr>
					<td class=b><img src='images/p.png'> <b>Имя</b></td>
					<td class=b><div id='name'>".change(sample, $user[name])."</div></td>
				</tr>
				<tr>
					<td class=b><img src='images/p.png'> <b>Дата рождения</b></td>
					<td class=b><div id='born'>".change(date, $user[born])."</div></td>
				</tr>
				<tr>
					<td class=b><img src='images/p.png'> <b>Пол</b></td>
					<td class=b>".change(sex, $user[sex])."</td>
				</tr>
				<tr>
					<td class=b><img src='images/p.png'> <b>E-mail</b></td>
					<td class=b>".change(sample, $user[email])."</td>
				</tr>
				<tr>
					<td class=b><img src='images/p.png'> <b>ICQ</b></td>
					<td class=b>".change(sample, $user[icq])."</td>
				</tr>
				<tr>
					<td class=b><img src='images/p.png'> <b>Моб. телефон</b></td>
					<td class=b>".change(sample, $user[mobile])."</td>
				</tr>
				<tr>
					<td class=b><img src='images/p.png'> <b>Skype</b></td>
					<td class=b>".change(sample, $user[skype])."</td>
				</tr>
				<tr>
					<td class=b><img src='images/p.png'> <b>Vkontakte.ru</b></td>
					<td class=b>".change(vk, $user[vk])."</td>
				</tr>
				</table>
			</center></th></tr>
		<tr><td class=up><b>Группа: </b>".change(team, $user[team])."</td></tr>
		</table>";
}
else if (isset($what) && $what=="tracks" && ($_SESSION["loggedIn"] || isset($id))) {
	if ($id) $uid = $id;
	else $uid = getUserIdByLogin($_SESSION["login"]);
	$tracks = mysql_query("SELECT * FROM tracks WHERE uid='".$uid."' AND status=1");
	printTracks($tracks);
}
else if (isset($what) && $what=="addtrack" && $_SESSION["loggedIn"]) {
	$uid = getUserIdByLogin($_SESSION["login"]);
	include("gmaps2/add.php");
}
else if (isset($what) && strlen($param) > 0) echo $error;
?>